package com.platform.conf

import javax.servlet.ServletContextEvent
import javax.servlet.ServletContextListener

class Log4jConfigListener : ServletContextListener {

    override fun contextDestroyed(servlet_context_event: ServletContextEvent) {
        System.getProperties().remove(log4j_dir_key)
    }

    override fun contextInitialized(servlet_context_event: ServletContextEvent) {
        val log4j_dir = servlet_context_event.servletContext.getRealPath("/")
        System.setProperty(log4j_dir_key, log4j_dir)
    }

    companion object {
        private val log4j_dir_key = "log4jDir"
    }
}